
<template>
  <div class="page-address-edit" data-log="地址">
    <form action="" v-on:submit.prevent="onSubmit">
    <div class="edit-box">
      <ul class="ui-list">
        <li class="ui-list-item">
          <div class="label">收货人：</div>
          <div class="ui-input"><input v-model="address.name" placeholder="真实姓名" name="name" maxlength="15" type="text">
          </div>
        </li>
        <li class="ui-list-item">
          <div class="label">手机号码：</div>
          <div class="ui-input"><input v-model="address.tel" placeholder="手机号" name="tel" id="tel" maxlength="13" type="tel"></div>
        </li>
        <li class="ui-list-item">
          <div class="label">所在地区：</div>
          <div class="ui-input">
            <input placeholder="省 市 区" v-model="address.pca" name="pcd" id="pca" maxlength="20" type="text"
                   readonly="readonly" value="">
          </div>
        </li>
        <li class="ui-list-item">
          <div class="label">街道地址：</div>
          <div class="ui-input"><input placeholder="详细地址" v-model="address.detail" name="detail" maxlength="120" type="text">
          </div>
        </li>
      </ul>
      <div class="save-button">
        <a href="javascript:;" class="ui-button" type="submit"><span>保存地址</span></a>
      </div>
    </div>
    </form>

    <div class="ui-mask" style="display:none;"></div>
    <div class="ui-pop" style="display:none;">
      <div class="ui-pop-content">
        <div class="region-list" id="city">

        </div>
      </div>
      <div class="ui-pop-title">选择所在地区</div>
      <div class="ui-pop-close"><a><span class="icon-10chahaokuang"></span></a></div>
    </div>

    <div class="popup-risk-check"></div>
  </div>
</template>
<script>

  export default {

    data() {
      return {

        addresses:[],
        address:[]

      }
    },
    updated() {
      $("input[name='pcd']").click(function () {
        $('.ui-mask').show();
        $('.ui-pop').show();
      });
    },

    methods: {
      onSubmit:function() {
        this.axios.post(`/address/address_create?token=${localStorage.token}`)
          .then((response) => {
            // console.log(response.data);
            // this.addresses = response.data.addresses;
            this.$router.push({name:'Address_list'})
          })

        // .catch((error)=>{
        //   console.log(error.response.data.error)
        // if(error.response.data.error=='token_invalid'){
        //     alert('非法登录')
        //   this.$router.push({name:'Login'})
        // }
        // })
      },
    },
  }
</script>


